import { useI18n } from '/@/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '/@/components/Table';
import { inMaintenanceInfoDataListData } from '/@/api/maintenance.management/inMaintenanceInfoData';

const { t } = useI18n('maintenance.management.inMaintenanceInfoData');

const modalProps = {
  title: t('维保设备信息记录表选择'),
};

const searchForm: FormProps = {
  baseColProps: { md: 8, lg: 6 },
  labelWidth: 90,
  schemas: [
    {
      label: t('维保任务ID'),
      field: 'maintenanceId',
      component: 'Input',
    },
    {
      label: t('添加时间'),
      field: 'createTime',
      component: 'DatePicker',
      componentProps: {
        format: 'YYYY-MM-DD HH:mm',
        showTime: { format: 'HH:mm' },
      },
    },
    {
      label: t('更新时间'),
      field: 'updateTime',
      component: 'DatePicker',
      componentProps: {
        format: 'YYYY-MM-DD HH:mm',
        showTime: { format: 'HH:mm' },
      },
    },
    {
      label: t('首次完成检测时间'),
      field: 'firstDetectionTime',
      component: 'DatePicker',
      componentProps: {
        format: 'YYYY-MM-DD HH:mm',
        showTime: { format: 'HH:mm' },
      },
    },
    {
      label: t('设备ID'),
      field: 'equipmentId',
      component: 'Input',
    },
    {
      label: t('状态'),
      field: 'state',
      component: 'Input',
    },
    {
      label: t('设备类型名称'),
      field: 'equipmentType',
      component: 'Input',
    },
    {
      label: t('设备类型编码'),
      field: 'equipmentTypeCode',
      component: 'Input',
    },
    {
      label: t('设备编码'),
      field: 'equipmentCode',
      component: 'Input',
    },
    {
      label: t('设备地址'),
      field: 'equipmentAddress',
      component: 'Input',
    },
    {
      label: t('设备名称'),
      field: 'equipmentName',
      component: 'Input',
    },
    {
      label: t('执行时间'),
      field: 'executeTime',
      component: 'Input',
    },
    {
      label: t('备注信息'),
      field: 'mark',
      component: 'Input',
    },
  ],
};

const tableColumns: BasicColumn[] = [
  {
    title: t('维保任务ID'),
    dataIndex: 'maintenanceId',
    key: 'a.maintenance_id',
    sorter: true,
    width: 230,
    align: 'left',
    slot: 'firstColumn',
  },
  {
    title: t('添加时间'),
    dataIndex: 'createTime',
    key: 'a.create_time',
    sorter: true,
    width: 130,
    align: 'center',
  },
  {
    title: t('更新时间'),
    dataIndex: 'updateTime',
    key: 'a.update_time',
    sorter: true,
    width: 130,
    align: 'center',
  },
  {
    title: t('首次完成检测时间'),
    dataIndex: 'firstDetectionTime',
    key: 'a.first_detection_time',
    sorter: true,
    width: 130,
    align: 'center',
  },
  {
    title: t('设备ID'),
    dataIndex: 'equipmentId',
    key: 'a.equipment_id',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('状态'),
    dataIndex: 'state',
    key: 'a.state',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('设备类型名称'),
    dataIndex: 'equipmentType',
    key: 'a.equipment_type',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('设备类型编码'),
    dataIndex: 'equipmentTypeCode',
    key: 'a.equipment_type_code',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('设备编码'),
    dataIndex: 'equipmentCode',
    key: 'a.equipment_code',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('设备地址'),
    dataIndex: 'equipmentAddress',
    key: 'a.equipment_address',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('设备名称'),
    dataIndex: 'equipmentName',
    key: 'a.equipment_name',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('执行时间'),
    dataIndex: 'executeTime',
    key: 'a.execute_time',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('备注信息'),
    dataIndex: 'mark',
    key: 'a.mark',
    sorter: true,
    width: 130,
    align: 'left',
  },
];

const tableProps: BasicTableProps = {
  api: inMaintenanceInfoDataListData,
  beforeFetch: (params) => {
    params['isAll'] = true;
    return params;
  },
  columns: tableColumns,
  formConfig: searchForm,
  rowKey: 'tid',
};

export default {
  modalProps,
  tableProps,
  itemCode: 'tid',
  itemName: 'tid',
  isShowCode: false,
};
